<template>
  <div class="amin-adminheader-container">
    <div class="title" @click="gotoIndex">
      <img src="../../assets/logo-icon1.png" width="50px" />
      <img src="../../assets/logo.png" width="160px" />
    </div>
    <div class="admin-info">
      <el-dropdown placement="bottom" :show-timeout="100">
        <div class="el-dropdown-link">
          <el-avatar
            :size="30"
            style="margin-right: 10px"
            src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
          />
          <span class="admin-name">{{ this.$store.state.user.username }}</span>
          <i class="el-icon-arrow-down el-icon--right"></i>
        </div>
        <el-dropdown-menu slot="dropdown">
          <div class="dropdown-top">
            <el-avatar
              :size="50"
              style="margin-right: 10px"
              src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
            />
            <div class="dropdown-top-text">
              <div class="admin-name">
                {{ this.$store.state.user.username }}
              </div>
              <div class="email">
                手机号：{{ this.$store.state.user.phone }}
              </div>
              <div class="email">邮箱：{{ this.$store.state.user.email }}</div>
            </div>
          </div>
          <el-dropdown-item @click.native="openAdminInfo"
            ><i class="el-icon-setting"></i> 账户设置</el-dropdown-item
          >
          <el-dropdown-item @click.native="logout"
            ><i class="el-icon-switch-button"></i> 退出登录
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    gotoIndex() {
      this.$router.push("/manage");
    },
    openAdminInfo: function () {
      this.$router.push("/adminInfo");
    },
    logout() {
      this.$store.commit("logout");
      this.$message.success("成功退出登录！");
      this.$router.replace("/login");
    },
  },
};
</script>

<style lang="scss">
.amin-adminheader-container {
  display: flex;
  justify-content: space-between;
  background-color: #00caa8;
  height: 100%;
  .title {
    margin-left: 100px;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: 2px;
    line-height: 60px;
    color: #353532;
    display: flex;
    align-items: center;
    cursor: pointer;
    span {
      font-size: 18px;
      font-weight: 400;
    }
  }
  .admin-info {
    display: flex;
    height: 60px;
    align-items: center;
    margin-right: 100px;
    font-size: 14px;
    .el-dropdown-link {
      display: flex;
      align-items: center;
      cursor: pointer;
      .admin-name {
        color: #1f1f1f;
      }
    }
  }
}
.el-dropdown-menu {
  top: 45px;
  padding: 10px 30px;
  border-radius: 10px;
  box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.1);
  background-color: #fbfbfb;
  .popper__arrow {
    display: none;
  }
  .dropdown-top {
    display: flex;
    align-items: center;
    .dropdown-top-text {
      font-size: 12px;
      color: #a29b9d;
      .admin-name {
        color: #321f1f;
        font-weight: 600;
        margin-bottom: 2px;
        font-size: 14px;
      }
      .email {
        font-size: 12px;
      }
    }
  }
  .el-dropdown-menu__item {
    background-color: #fff;
    border-radius: 10px;
    margin: 10px 0;
  }
}
</style>
